import fetch from '../../utils/request';

export async function getWebApiConfigsAxios(userName){//获取当前用户所有webapi连接配置
  const params = {
    userName
  }
  return fetch({
    url: '/api/connectionConfig/getWebApiConfigs',
    method: 'get',
    params
  });
}

export async function deleteWebConAxios(params){//删除web接口导入的配置信息
  return fetch({
    url: '/api/webapi/deleteCon',
    method: 'delete',
    params
  });
}

export async function editWebConAxios(params){//编辑连接配置
  return fetch({
    url: '/api/webapi/editCon',
    method: 'put',
    params
  });
}

export async function getAllFieldsAxios(databaseId){//获取配置中的所有字段
  const params = {
    databaseId
  }
  return fetch({
    url: '/api/webapi/getAllFields',
    method: 'get',
    params
  });
}

export async function webApiGetConAxios(id){//获取指定连接配置
  const params = {
    id
  }
  return fetch({
    url: '/api/webapi/getCon',
    method: 'get',
    params
  });
}

export async function webApiSaveConAxios(params){//保存连接配置
  return fetch({
    url: '/api/webapi/saveCon',
    method: 'post',
    params
  });
}

export async function webApiTestConAxios(data){//测试连接配置
  const params = {
    data
  }
  return fetch({
    url: '/api/webapi/testCon',
    method: 'get',
    params
  });
}